package com.purchase.ml.bean.res.shoppingcart;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;

/**
 * Created by kyyang on 2021/2/28 16:34
 */
@ApiModel("购物车内容")
public class ShoppingCartRes {

    @ApiModelProperty("商品编号")
    private Long productId;

    @ApiModelProperty("商品图片")
    private String picUrl;

    @ApiModelProperty("商品名")
    private String productName;

    @ApiModelProperty("产品型号")
    private String productModel;

    @ApiModelProperty("数量")
    private int quantity;

    @ApiModelProperty("单价")
    private BigDecimal price;

    @ApiModelProperty("小计")
    private BigDecimal total;


    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public String getPicUrl() {
        return picUrl;
    }

    public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getProductModel() {
        return productModel;
    }

    public void setProductModel(String productModel) {
        this.productModel = productModel;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public BigDecimal getTotal() {
        if(price==null){
            return BigDecimal.ZERO;
        }
        return this.price.multiply(BigDecimal.valueOf(this.quantity));
    }

    public void setTotal(BigDecimal total) {
        this.total = total;
    }
}
